<!--
  Generated template for the ResoursePage page.

  See http://ionicframework.com/docs/components/#navigation for more info on
  Ionic pages and navigation.
-->
<ion-header>

  <ion-navbar color="mainColor">
    <ion-title *ngIf="!showSearchBar">资源</ion-title>
    <ion-searchbar
      placeholder="请输入关键词"
      [(ngModel)]="searchText"
      [showCancelButton]="false"
      *ngIf="showSearchBar"
    >
    </ion-searchbar>
    <ion-buttons *ngIf="!showSearchBar" end>
      <button ion-button icon-only (click)="showSearchBar = !showSearchBar">
        <ion-icon name="search"></ion-icon>
      </button>
    </ion-buttons>
    <ion-buttons *ngIf="showSearchBar" end>
      <button ion-button (click)="search()">
        搜索
      </button>
      <button ion-button icon-only (click)="showSearchBar = !showSearchBar">
        <ion-icon name="close"></ion-icon>
      </button>
    </ion-buttons>
  </ion-navbar>
</ion-header>


<ion-content padding>
  <ion-refresher (ionRefresh)="doRefresh($event)">
    <ion-refresher-content pullingIcon="arrow-dropdown" pullingText="下拉刷新" refreshingSpinner="circles"  refreshingText="努力刷新数据中...">
    </ion-refresher-content>
  </ion-refresher>
  <ul *ngIf="resourceList">
    <li *ngFor="let item of resourceList;let i=index" (click)="ViewSource(item.source_path,item.source_name,item.source_id,item.source_type,(item.source_id+'-'+item.teacher_id+'-'+item.source_type),item.unit_id,item.teacher_id,item.class_type,item.course_class_id,item.isCheck,item.start_answer)">
      <div [ngSwitch]="item.source_type"><!--案例40002，网页链接40003，ppt 40005，视频40009，图片40010-->
        <img *ngSwitchCase="40002" src="./assets/imgs/src-case.jpg" alt="">
        <img *ngSwitchCase="40003" src="./assets/imgs/src-link.jpg" alt="">
        <img *ngSwitchCase="40005" src="./assets/imgs/src-lecture.jpg" alt="">
        <img *ngSwitchCase="40009" src="./assets/imgs/src-video.jpg" alt="">
        <img *ngSwitchCase="40010" src="./assets/imgs/src-image.jpg" alt="">
        <img *ngSwitchCase="40011" src="./assets/imgs/src-pdf.jpg" alt="">
      </div>
      <div>
        <p class="title">{{item.source_name}}</p>
        <p class="info"><span>发布时间：{{item.create_time}}</span><span class="ex">{{item.score}}经验</span></p>
        <p class="info" *ngIf="item.deadline!=null&&item.deadline!=''">截止时间：{{item.deadline}}</p>
      </div>
      <div (click)="downLoadFile(item.isCheck,item.source_path,$event,item.source_id,item.source_type,i,item.unit_id,item.teacher_id,item.class_type,item.course_class_id,item.start_answer)">
<!--        <span>新</span>
        <ion-icon name="md-arrow-down" *ngIf="item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011'"></ion-icon>有哪些资源可下载待检查 视频，讲义，pdf-->

        <!--isCheck:0-未下载（未查看） 1-已下载（下载成功） 2-下载中 3-刚刚下载失败 4-上一次下载失败-->
        <ion-icon name="md-arrow-down" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==0"></ion-icon><!--有哪些资源可下载待检查 视频，讲义，pdf-->
        <ion-icon name="md-checkmark" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==1"></ion-icon>
        <ion-icon name="md-pause" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==2"></ion-icon>
        <ion-icon name="md-close" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==3"></ion-icon>
        <ion-icon name="md-help" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==4"></ion-icon>
      </div>
    </li>
  </ul>
  <span *ngIf="!resourceList">暂无数据</span>
  <ion-infinite-scroll (ionInfinite)="doInfinite($event)" threshold="100px">
    <ion-infinite-scroll-content
      loadingSpinner="bubbles"
      loadingText="加载更多">
    </ion-infinite-scroll-content>
  </ion-infinite-scroll>
</ion-content>
